<template>
  <div class="folder-path-input">
    <div class="input-button-container">
      <label for="folderPathInput">请输入pdf文件夹路径:</label>
      <input type="text" id="folderPathInput" v-model="folderPath" />
      <button @click="sendFolderPath">发送到后端</button>
    </div>
  </div>
</template>

<script>
import { postPdfFolderPath } from '../../services/PdfService/PdfApi';

export default {
  name: 'FolderPdfputComponent',
  data() {
    return {
      folderPath: ''
    };
  },
  methods: {
    async sendFolderPath() {
      if (!this.folderPath.trim()) {
        alert('请输入一个有效的文件夹路径。');
        return;
      }

      try {
        await postPdfFolderPath(this.folderPath);
        alert('文件夹路径已成功发送到后端。');
      } catch (error) {
        alert('发送文件夹路径时出错:', error.message);
      }
    }
  }
};
</script>

<style scoped>
.folder-path-input {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 20px;
}

.input-button-container {
  display: flex;
  align-items: center;
}

label {
  margin-right: 10px;
}

input {
  width: 300px;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 5px;
  margin-right: 10px;
}

button {
  background-color: #ff5500;
  color: #fff;
  border: none;
  padding: 10px 20px;
  cursor: pointer;
  border-radius: 5px;
}

button:hover {
  background-color: #0056b3;
}
</style>
